{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1222
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i,tt:longint;
	a,b,c,d:int64;
	f:boolean;
 
procedure swap(var a,b:int64);
 
var
	t:int64;
 
begin
t:=a;
a:=b;
b:=t;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(tt);
for i:=1 to tt do begin
	read(a,b,c,d);
	f:=false;
	while b>0 do begin
		if (b=d) and (c<a) and ((c - a mod b)	mod b = 0) then begin
			f:=true;
			break;
		end;
		a:=a mod b;
		swap(a,b);
	end;
	if f then writeln('YES') else writeln('NO');
end;
end.